<?php 
function generateThumb($path){
    try {
        $yearMonth = date('Ym');
        $VIDEO_IMAGE_BASEW_PATH = dirname(__FILE__).DIRECTORY_SEPARATOR."uploadimg".DIRECTORY_SEPARATOR."video";
        $video_image_path = $VIDEO_IMAGE_BASEW_PATH.DIRECTORY_SEPARATOR.$yearMonth.DIRECTORY_SEPARATOR;
        
        if(!file_exists($video_image_path)){
           mkdir($video_image_path, 0777);  
        }
        $imageName = 'pocle_'.date("YmdGis").'_'.rand(1000,9999).".jpg";
        $imagePath = 'D:/wwwroot/to.goojje.com/midnight/'.$imageName;
        
        $frame = 1;
        $mov = new ffmpeg_movie($path);
        
        $img = sprintf("%s/".$imageName, $video_image_path, $frame);
        $ff_frame = $mov->getFrame($frame);
        if ($ff_frame) {
            $gd_image = $ff_frame->toGDImage();
            if ($gd_image) {
                imagejpeg($gd_image, $img);
                imagedestroy($gd_image);
            }
        }
        return $imagePath;
    }catch(Exception $e){
        return "";
    }
}
$ttt = time();
$phpwsh=new COM("Wscript.Shell") or die("Create Wscript.Shell Failed!"); 
$exec=$phpwsh->exec("cmd.exe /c C:/ffmpeg.exe -i D:/aa.mp4 -f image2 -ss 5 -s 120*90 -vframes 1 D:/wwwroot/to.goojje.com/midnight/swf/$ttt.jpg"); 


?>
